from flask import Flask, request, jsonify

app = Flask(__name__)

# 存储PC1发送的字符串
shared_data = None
shared_data2=None
@app.route('/send_data', methods=['POST'])
def send_data():
    global shared_data
    # 接收PC1发送的字符串
    shared_data = request.json.get('data')
    return jsonify({'status': 'success'}), 200
@app.route('/send_data2', methods=['POST'])
def send_data2():
    global shared_data2
    # 接收PC1发送的字符串
    shared_data2 =request.json.get('data')
    return jsonify({'status': 'success'}), 200

@app.route('/get_processed_data2', methods=['POST'])
def get_processed_data2():
    global shared_data
    # PC2请求处理后的数据
    if shared_data:
        # 假设处理函数是简单的字符串反转
        processed_data = shared_data
        shared_data=None
        return jsonify({'status':'data','processed_data': processed_data}), 200
    else:
        return jsonify({'status': 'no data'}), 404
@app.route('/get_processed_data', methods=['POST'])
def get_processed_data():
    global shared_data2
    # PC2请求处理后的数据
    if shared_data2:
        # 假设处理函数是简单的字符串反转
        processed_data = shared_data2
        shared_data2=None
        return jsonify({'status':'data','processed_data': processed_data}), 200
    else:
        return jsonify({'status': 'no data'}), 404
if __name__ == '__main__':
    app.run(host="0.0.0.0",port=80)
